import request from './request'

/**
 * 测试执行API
 */

// 执行单个测试用例
export function executeTestCase(caseId, data) {
  return request({
    url: `/execution/execute/${caseId}`,
    method: 'post',
    data
  })
}

// 批量执行测试用例
export function batchExecuteTestCases(data) {
  return request({
    url: '/execution/batch-execute',
    method: 'post',
    data
  })
}

// 数据驱动执行
export function dataDrivenExecute(data) {
  return request({
    url: '/execution/data-driven',
    method: 'post',
    data
  })
}

// 获取执行任务状态
export function getTaskStatus(taskId) {
  return request({
    url: `/execution/task/${taskId}`,
    method: 'get'
  })
}

// 取消执行任务
export function cancelTask(taskId) {
  return request({
    url: `/execution/task/${taskId}/cancel`,
    method: 'post'
  })
}

// 获取执行历史
export function getExecutionHistory(params) {
  return request({
    url: '/execution/history',
    method: 'get',
    params
  })
}

// 重新执行
export function reExecute(executionId) {
  return request({
    url: `/execution/${executionId}/re-execute`,
    method: 'post'
  })
}
